﻿Type.registerNamespace('SPGoogleMapPart');

var _webPartPageComponentId;
SPGoogleMapPart.CustomPageComponent = function SPGoogleMapPart_CustomPageComponent(webPartPcId) {
    this._webPartPageComponentId = webPartPcId;
    SPGoogleMapPart.CustomPageComponent.initializeBase(this);
}

SPGoogleMapPart.CustomPageComponent.prototype = {

    init: function SPGoogleMapPartt_CustomPageComponent$init() { },

    getFocusedCommands: function SPGoogleMapPart_CustomPageComponent$getFocusedCommands() {
        return ['SPGoogleMapPart.EnableCustomTab', 'SPGoogleMapPart.EnableContextualGroup', 'SPGoogleMapPart.EnableZoomGroup', 'ZoomInCommand', 'ZoomOutCommand', 'SPGoogleMapPart.EnableMapTypeGroup', 'HybridCommand', 'RoadMapCommand', 'SatelliteCommand', 'TerrainCommand', 'SPGoogleMapPart.EnablePanGroup', 'LeftCommand', 'UpCommand', 'DownCommand', 'RightCommand'];
    },

    getGlobalCommands: function ConnectedWebPart_CustomPageComponent$getGlobalCommands() {
        return [];
    },

    isFocusable: function ConnectedWebPart_CustomPageComponent$isFocusable() {
        return true;
    },

    canHandleCommand: function ConnectedWebPart_CustomPageComponent$canHandleCommand(commandId) {
        return true;
    },

    handleCommand: function ConnectedWebPart_CustomPageComponent$handleCommand(commandId, properties, sequence) {
        if (commandId === 'ZoomInCommand') {
            actzoom = map.getZoom();
            map.setZoom(actzoom + 1);
        }
        if (commandId === 'ZoomOutCommand') {
            actzoom = map.getZoom();
            map.setZoom(actzoom - 1);
        }
        if (commandId === 'HybridCommand') {
            map.setMapTypeId('hybrid');
        }
        if (commandId === 'RoadMapCommand') {
            map.setMapTypeId('roadmap');
        }
        if (commandId === 'SatelliteCommand') {
            map.setMapTypeId('satellite');
        }
        if (commandId === 'TerrainCommand') {
            map.setMapTypeId('terrain');
        }
        
        if (commandId === 'LeftCommand') {
            map.panBy(-10,0);
        }
        if (commandId === 'UpCommand') {
            map.panBy(0,-10);
        }
        if (commandId === 'DownCommand') {
            map.panBy(0,10);
        }
        if (commandId === 'RightCommand') {
            map.panBy(10,0);
        }

    },

    getId: function ContextualTabWebPart_CustomPageComponent$getId() {
        return this._webPartPageComponentId;
    }
}

SPGoogleMapPart.CustomPageComponent.registerClass('SPGoogleMapPart.CustomPageComponent', CUI.Page.PageComponent);
SP.SOD.notifyScriptLoadedAndExecuteWaitingJobs("SPGoogleMapPartPageComponent.js");